#include "BoardAssembly.h"
#include "IEthernet.h"


BoardAssembly::BoardAssembly(IArduino& a, IEthernet& e, ILogger& l, String name) : 
arduino_(a), ethernet_(e), logger_(l), factory_(a, router_, l), _name(Service::allocateString(name)), 
		router_(l), gateway_(a, router_, ethernet_, l),
		conf_(a, router_, factory_, name, l),
		mem_(a, router_, l){
			//if(ethernet_.isInitialized()){
			router_.addService(gateway_);
			//}
			router_.addService(conf_);
			router_.addService(mem_);
}
BoardAssembly::~BoardAssembly(){
	free(_name);
}

void BoardAssembly::loop() {
	long miliseconds = arduino_.milliseconds();
	router_.tick(miliseconds);
}

MessageRouter& BoardAssembly::getRouter(){
	return router_;
}